//
//  MyViewController.m
//  Qyer
//
//  Created by dlios on 15/10/16.
//  Copyright (c) 2015年 GF. All rights reserved.
//

#import "MyViewController.h"
#import "BaseHeader.h"
@interface MyViewController ()<UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate>
{
    UIView *email;
}
@property (nonatomic,strong)NSMutableArray *imageArray;
@property (nonatomic,strong)NSMutableArray *lableArray;
@property (nonatomic,strong)UITextField *titleField;
@property (nonatomic,strong)UITextField *summaryFirld;
@property (nonatomic,assign)NSInteger temp;
@end

@implementation MyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    _imageArray = [NSMutableArray arrayWithObjects:@"start.png", @"clear.png", @"about.png", @"youjian.png", nil];
    _lableArray = [NSMutableArray arrayWithObjects:@"    收藏", @"    清扫", @"    关于", @"    反馈", nil];
    
    UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 300 * HEIGHT)];
    [image setImage:[UIImage imageNamed:@"beijing.jpg"]];
    [self.view addSubview:image];
    
    _table = [[UITableView alloc] initWithFrame:CGRectMake(0, 300 * HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - 300 * HEIGHT)];
    [_table setDelegate:self];
    [_table setBounces:NO];
    [_table setDataSource:self];
    [self.view addSubview:_table];
    
    UIView *view = [[UIView alloc] init];
    _table.tableFooterView = view;
    
    email = [[UIView alloc] initWithFrame:CGRectMake(0, 400 * HEIGHT, SCREEN_HEIGHT, 155 * HEIGHT)];
    [email setHidden:YES];
    [self.view addSubview:email];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 4;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50 * HEIGHT;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *guoFeng = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:guoFeng];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:guoFeng];
    }
    
    [cell.imageView setImage:[UIImage imageNamed:[_imageArray objectAtIndex:indexPath.row]]];
    [cell.textLabel setText:[_lableArray objectAtIndex:indexPath.row]];
    [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
       
    }else if (indexPath.row == 1){
        NSUInteger size = [[SDImageCache sharedImageCache]getSize];
        CGFloat cache = size/1024./1024;
        NSString *str = [NSString stringWithFormat:@"一共清除了%.2fM",cache];
        [[SDImageCache sharedImageCache]clearDisk];
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:str delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alert show];
    }else if(indexPath.row == 2){
        GFAboutViewController *about = [[GFAboutViewController alloc] init];
        [self.navigationController pushViewController:about animated:YES];
    }else{
        if (![MFMailComposeViewController canSendMail]) {
            return;
        }
        
        MFMailComposeViewController * mailCVC = [[MFMailComposeViewController alloc] init];
        [mailCVC setToRecipients:@[@"329285644@qq.com"]];
        [mailCVC setMessageBody:@"请输入您的反馈 :" isHTML:NO];
        [mailCVC setSubject:@"请输入您的主题 :"];
        [mailCVC setMailComposeDelegate:self];
        [self presentViewController:mailCVC animated:YES completion:nil];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
